var common = require('../../../utils/util.js')
var app = getApp();

Page({
    data: {
        // text:"这是一个页面"
        iconUrl: ['../../../image/icon-success.png'],
        arrow: '../../../image/arrowright_gray.png',
        orderId: "",
        itemTitle: ""
    },
    onLoad: function (options) {
        // 页面初始化 options为页面跳转所带来的参数
      let orderId = options.orderId;
	    this.setData({
        "orderId": orderId
      });
      this.getOrderInfo();
    },
    onReady: function () {
        // 页面渲染完成
        wx.setNavigationBarTitle({ title: '支付成功' });
    },
    onShow: function () {
        // 页面显示

        wx.setNavigationBarTitle({ title: "支付成功" })
    },
    onHide: function () {
        // 页面隐藏
    },
    onUnload: function () {
        // 页面关闭
    },
    payDetails: function () {
        if (this.data.orderId == '') {
            wx.showToast({
                title: '请稍候',
                icon: 'loading',
                duration: 2000,
                mask: true
            });
        } else {
            wx.redirectTo({
                url: '../../orderInfo/orderDetails/orderDetails?orderId=' + this.data.orderId
            });
        }
    },
    getOrderInfo: function (e) {
        var param = {
	        url: '/wx/carViola/getOrder.ajax',
	        para: {
              "orderId": this.data.orderId  //'Test1726934550514'// this.data.orderId  
          }
        };
        app.requestSdkForNeedLogin({
            param: param,
            beforeSend: () => {
                //发送请求之前执行
                wx.showToast({
                    title: '请稍候',
                    icon: 'loading',
                    duration: 10000,
                    mask: true
                });
            },
            success: data => {
                if (data.code ==1000 && data.body.orderViolationList) {
                    let carList = data.body;
                    let orderVoliationsList = data.body.orderViolationList;
                    let itemTitle = "";
                    itemTitle += orderVoliationsList[0].carNumber + "，" + orderVoliationsList[0].locaitonName;

                    if (orderVoliationsList.length > 1) {
                        itemTitle += "等地";
                    }
                    itemTitle += "违章";
                    this.setData({
                        itemTitle: itemTitle.replace(null,'')
                    });
                } else {
                    toast.show(this, data.msg)
                }
            },
            complete: data => {
                wx.hideToast();
            }
        });

    },
    onShareAppMessage: function () {
        return {
            title: '还在为违章处理排队烦恼吗？',
            desc: '邮证查办违章，免费查询，实时提醒，快速在线缴罚款，车主最贴心的车务管家！ ',
            path: 'pages/carInfo/list/list'
        }
    }
})